/* GUI CONVERTED from reoptr12.p (converter v1.76) Sun Aug 25 20:59:46 2002 */
/* reoptr12.p - DOWNTIME TRANSACTION BY PART (REPETITIVE)               */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.11.1.2 $                                                         */
/*V8:ConvertMode=Maintenance                                            */
/* REVISION: 5.0      LAST MODIFIED: 05/15/89   BY: emb   */
/* REVISION: 5.0      LAST MODIFIED: 10/17/90   BY: emb *B801*/
/* REVISION: 6.0      LAST MODIFIED: 09/25/90   BY: SMM *D072*/
/* REVISION: 6.0      LAST MODIFIED: 10/18/90   BY: SMM *D108*/
/* REVISION: 6.0      LAST MODIFIED: 11/20/90   BY: emb *D223*/
/* REVISION: 6.0      LAST MODIFIED: 03/22/91   BY: emb *D448*/
/* REVISION: 6.0      LAST MODIFIED: 04/09/91   BY: WUG *D503*/
/* REVISION: 6.0      LAST MODIFIED: 06/14/91   BY: emb *D705*/
/* REVISION: 6.0      LAST MODIFIED: 08/09/91   BY: pma *D806*/
/* REVISION: 7.0      LAST MODIFIED: 10/08/91   BY: pma *F003*          */
/* REVISION: 7.0      LAST MODIFIED: 03/09/92   BY: smm *F230*/
/* REVISION: 7.0      LAST MODIFIED: 03/22/92   BY: pma *F089*/
/* REVISION: 7.0      LAST MODIFIED: 06/17/92   BY: emb *F662*/
/* REVISION: 7.0      LAST MODIFIED: 10/13/92   BY: emb *G184*/
/* REVISION: 7.0      LAST MODIFIED: 03/01/93   BY: emb *G760*/
/* REVISION: 7.3      LAST MODIFIED: 08/31/93   BY: emb *GE62*(rev only)*/
/* REVISION: 7.3      LAST MODIFIED: 10/31/94   BY: WUG *GN76*          */
/* REVISION: 7.3      LAST MODIFIED: 12/23/94   BY: cpp *FT95*          */
/* REVISION: 7.3      LAST MODIFIED: 05/11/95   BY: ais *G0MM*          */
/* REVISION: 7.3      LAST MODIFIED: 08/12/95   BY: ais *G0TC*          */
/* REVISION: 7.3      LAST MODIFIED: 11/28/95   BY: jym *F0WD*          */
/* REVISION: 7.3      LAST MODIFIED: 03/27/96   BY: jym *G1Q9*          */
/* REVISION: 8.6      LAST MODIFIED: 06/11/96   BY: aal *K001*          */

/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan   */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb          */
/* Old ECO marker removed, but no ECO header exists *F0PN*                */
/* Old ECO marker removed, but no ECO header exists *F331*                */
/* $Revision: 1.11.1.2 $    BY: Vivek Gogte           DATE: 08/06/02  ECO: *N1QQ*  */

/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE */
{mfdtitle.i "2+ "}

{gldydef.i new}
{gldynrm.i new}

define new shared variable gldetail      like mfc_logical no-undo initial no.
define new shared variable gltrans       like mfc_logical no-undo initial no.
define new shared variable wr_recno      as   recid.
define new shared variable wc_recno      as   recid.
define new shared variable op_recno      as   recid.
define new shared variable comp          like ps_comp.
define new shared variable eff_date      as   date.
define new shared variable operation     like ps_op.
define new shared variable wo_recid      as   recid.
define new shared variable wo_recno      as   recid.
define new shared variable ophist_recid  as   recid.
define new shared variable pay_rate      like emp_pay_rate.
define new shared variable last_date     like op_date.
define new shared variable old_emp       like op_emp.
define new shared variable shift         like op_shift.
define new shared variable earn          like op_earn.
define new shared variable site          like rps_site     no-undo.
define new shared variable continue      as   logical      initial no.
define new shared variable emp_recno     as   recid.
define new shared variable prev_found    like mfc_logical.
define new shared variable prline        like rps_line     no-undo.
define new shared variable part          like op_part      no-undo.
define new shared variable op            like ps_op        no-undo.
define new shared variable schedule_id   like wo_lot.
define new shared variable undo-all      like mfc_logical  no-undo.
define new shared variable bom_code      as   character    format "x(18)"
                                         label "BOM Code".
define new shared variable routing       as   character    format "x(18)"
                                         label "Routing".
define new shared variable input_total   as   decimal      format "->>9.9<<"
                                         label "Input Total".
define new shared variable control_total like input_total
                                         label "Control Total".

define new global shared variable global_rsntyp as character.

define variable start_setup as   character format "99:99:XX"
   label "Start Time"                                              no-undo.
define variable downtime    like input_total extent 5
   label "Down Time"                                               no-undo.
define variable down_rsn    like rsn_code    extent 5
   label "Reason"                                                  no-undo.
define variable stop_setup  like start_setup
   label "Elapsed or Stop Time"                                    no-undo.
define variable yn          like mfc_logical                       no-undo.
define variable ref         like glt_ref                           no-undo.
define variable wr_recid    as   recid                             no-undo.
define variable start_run   like start_setup                       no-undo.
define variable stop_run    like stop_setup                        no-undo.
define variable date_change as   integer                           no-undo.
define variable elapse      as   decimal  format ">>>>>>>>.999"    no-undo.
define variable trnbr       like op_trnbr format ">>>>>>>9"        no-undo.
define variable wrnbr       like wr_nbr                            no-undo.
define variable i           as   integer                           no-undo.
define variable j           as   integer                           no-undo.
define variable qty         like op_qty_comp                       no-undo.
define variable rsn_desc1   like rsn_desc                          no-undo.
define variable rsn_desc2   like rsn_desc                          no-undo.
define variable rsn_desc3   like rsn_desc                          no-undo.
define variable msg-type    as   integer                           no-undo.
define variable locked-file as   character                         no-undo.
define variable msg-counter as   integer                           no-undo.
define variable ptstatus    like pt_status                         no-undo.
define variable down_desc   like rsn_desc extent 5                 no-undo.

define new shared frame a.
define new shared frame b.

define buffer ophist for op_hist.

assign
   last_date = today
   site      = global_site.

/* FRAME a DEFINITION */
{reopf10a.i}

/* FRAME b DEFINITION */
{reopf12b.i}

/* DISPLAY */
view frame a.
view frame b.

for first ea_mstr
   fields (ea_desc ea_earn ea_rate ea_type)
   where ea_type = "1"
no-lock:

   earn = ea_earn.
end. /* FOR FIRST ea_mstr */

for first mfc_ctrl
   fields (mfc_field mfc_logical)
   where mfc_field = "rpc_using_new"
no-lock:

   if mfc_logical = true
   then do:

      /* USE OF THIS FUNCTION NOT ALLOWED BECAUSE NEW REPETITIVE ENABLED */
      {pxmsg.i &MSGNUM=5122 &ERRORLEVEL=3}
      message.
      message.
      undo, leave.
   end. /* IF mfc_logical = true */

end. /* FOR FIRST mfc_ctrl */

mainloop:
repeat:
/*GUI*/ if global-beam-me-up then undo, leave.


   continue = no.
   {gprun.i ""reoptr2a.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   if not continue
   then
      leave mainloop.

   for first emp_mstr
      fields (emp_pay_rate emp_pay_type)
      where recid(emp_mstr) = emp_recno
      no-lock:
   end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* FOR FIRST emp_mstr */

   repeat with frame b:
/*GUI*/ if global-beam-me-up then undo, leave.


      prompt-for
         op_part
         op_wo_op
         prline
         with frame b
      editing:

         if frame-field = "op_part"
         then do:

            /* FIND NEXT/PREVIOUS RECORD */
            {mfnp.i pt_mstr op_part pt_part op_part pt_part pt_part}

            if recno <> ?
            then do:

               for first ptp_det
                  fields (ptp_bom_code ptp_part ptp_routing ptp_site)
                  where ptp_part = pt_part
                  and   ptp_site = site
                  no-lock:
               end. /* FOR FIRST ptp_det */

               display
                  pt_part @ op_part
                  pt_desc1.

               if available ptp_det
               then do:

                  if ptp_routing > ""
                  then
                     routing = ptp_routing.
                  else
                     routing = "".

                  if ptp_bom_code > ""
                  then
                     bom_code = ptp_bom_code.
                  else
                     bom_code = "".
               end. /* IF AVAILABLE ptp_det */

               else do:

                  if pt_routing > ""
                  then
                     routing = pt_routing.
                  else
                     routing = "".

                  if pt_bom_code > ""
                  then
                     bom_code = pt_bom_code.
                  else
                     bom_code = "".
               end. /* IF NOT AVAILABLE ptp_det */

               display
                  pt_part @ op_part
                  pt_desc1.

               for first ro_det
                  fields (ro_desc ro_op ro_routing)
                  where ro_routing = if routing > ""
                                     then
                                        routing
                                     else
                                        pt_part
                  no-lock:
               end. /* FOR FIRST ro_det */

               if available ro_det
               then
                  display
                     ro_op @ op_wo_op
                     ro_desc.

               else
                  display
                     "" @ op_wo_op
                     "" @ ro_desc.

               display
                  "" @ prline
                  "" @ ln_desc.

               for each lnd_det
                  fields (lnd_line lnd_part lnd_site lnd_start)
                  where lnd_site = site
                    and lnd_part = pt_part
                    and (lnd_start <= input last_date or lnd_start = ?)
                  no-lock
                  with frame b:

                  for first ln_mstr
                     fields (ln_desc ln_line ln_site)
                     where ln_line = lnd_line
                     and   ln_site = lnd_site
                     no-lock:
                  end. /* FOR FIRST ln_mstr */

                  if available ln_mstr
                  then
                     display
                        ln_line @ prline
                        ln_desc.

                  else
                     display
                        "" @ prline
                        "" @ ln_desc.

                  leave.
               end. /* FOR EACH lnd_det ... */

               display
                  routing
                  bom_code
               with frame b.

            end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* IF recno <> ? */

            recno = ?.

         end. /* IF frame-field = "op_part" */

         else if frame-field = "op_wo_op"
            and can-find (pt_mstr where pt_part = input op_part)
         then do:

            for first pt_mstr
               fields (pt_bom_code pt_desc1 pt_part pt_routing)
               where pt_part = input op_part
               no-lock:
            end. /* FOR FIRST pt_mstr */

            for first ptp_det
               fields (ptp_bom_code ptp_part ptp_routing ptp_site)
               where ptp_part = pt_part
               and   ptp_site = site
               no-lock:
            end. /* FOR FIRST ptp_det */

            /* FIND NEXT/PREVIOUS RECORD */
            {mfnp01.i ro_det op_wo_op ro_op
               "if available ptp_det
                then
                   if ptp_routing > """"
                   then
                      ptp_routing
                   else
                      ptp_part
                else
                   if pt_routing > """"
                   then
                      pt_routing
                   else
                      pt_part"
               ro_routing ro_routing}

            if recno <> ?
            then
               display
                  ro_op @ op_wo_op
                  ro_desc.
         end. /* ELSE IF frame-field = "op_wo_op" */

         else if frame-field = "prline"
         then do:

            {mfnp05.i lnd_det lnd_line
               "lnd_site = input site and lnd_part = input op_part"
               lnd_line "input prline"}

            if recno <> ?
            then do:

               for first ln_mstr
                  fields (ln_desc ln_line ln_site)
                  where ln_line = lnd_line
                  and   ln_site = lnd_site
                  no-lock:
               end. /* FOR FIRST ln_mstr */

               display
                  lnd_line @ prline.

               if available ln_mstr
               then
                  display
                     ln_desc.

            end. /* IF recno <> ? */
         end. /* ELSE IF frame-field = "prline" */

         else do:
            status input stline[3].
            readkey.
            apply lastkey.
         end.

      end. /* PROMPT-FOR ... */

      for first pt_mstr
         fields (pt_bom_code pt_desc1 pt_part pt_routing)
         where pt_part = input op_part
         no-lock:
      end. /* FOR FIRST pt_mstr */

      if not available pt_mstr
      then do:

         /* ITEM NUMBER DOES NOT EXIST */
         {pxmsg.i &MSGNUM=16 &ERRORLEVEL=3}
         undo, retry.
      end. /* IF NOT AVAILABLE pt_mstr  */

      assign
         prline.

      for first ln_mstr
         fields (ln_desc ln_line ln_site)
         where ln_site = site
         no-lock:
      end. /* FOR FIRST ln_mstr */

      if available ln_mstr
         or prline <> ""
      then do:

         for first ln_mstr
            fields (ln_desc ln_line ln_site)
            where ln_line = prline
            and   ln_site = site
            no-lock:
         end. /* FOR FIRST ln_mstr */

         if not available ln_mstr
         then do:

            /* SITE PRODUCTION LINE DOES NOT EXIST */
            {pxmsg.i &MSGNUM=8526 &ERRORLEVEL=3}
            next-prompt
               prline.
            display
               "" @ ln_desc.
            undo,retry.
         end. /* IF NOT AVAILABLE ln_mstr */

         display
            ln_desc.

      end. /* IF AVAILABLE ln_mstr ... */

      else
         display "" @ ln_desc.

      /* SECTION TO LOCATE PROPER SCHEDULE TO UPDATE */
      assign
         part = input op_part
         op   = input op_wo_op.

      {gprun.i ""reoptr1b.p""
         "(site, prline, part, op, last_date,
           output routing, output bom_code, output schedule_id)"}
/*GUI*/ if global-beam-me-up then undo, leave.


      if keyfunction(lastkey) = "end-error"
      then
         undo, retry.

      if schedule_id = ?
      then do:

         msg-type = 3.
         /* UNEXPLODED SCHEDULE WITH CONSUMPTION PERIOD */
         {pxmsg.i &MSGNUM=325 &ERRORLEVEL=msg-type}
         next-prompt
            op_part.
         undo, retry.
      end. /* IF schedule_id = ? */

      /* LOCATE PROPER ROUTING AND BOM CODE */
      {gprun.i ""reop12a.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


      if keyfunction(lastkey) = "end-error"
      then
         undo, retry.

      if undo-all
      then
         undo, retry.

      for first wo_mstr
         where recid(wo_mstr) = wo_recno
         no-lock:
      end. /* FOR FIRST wo_mstr */

      for first wr_route
         fields (wr_desc wr_lot wr_mch wr_nbr wr_part wr_wkctr)
         where recid(wr_route) = wr_recno
         no-lock:
      end. /* FOR FIRST wr_route */

      if available ro_det
      then
         display
            ro_desc.
      else
         display
            wr_desc @ ro_desc.

      for first pt_mstr
         fields (pt_bom_code pt_desc1 pt_part pt_routing)
         where pt_part = wr_part
         no-lock:
      end. /* FOR FIRST pt_mstr */

      if available pt_mstr
      then
         display
            pt_desc1.

      else
         display
            " " @ pt_desc1.

      status input.

      do transaction with frame b:
/*GUI*/ if global-beam-me-up then undo, leave.


         create op_hist.

         {mfnoptr.i}

         assign
            op_wo_nbr    = wr_nbr
            op_emp
            op_part
            op_wo_op
            op_shift     = shift
            op_wo_lot    = wr_lot
            op_type      = "DOWNTIME"
            op_tran_date = today
            op_wkctr     = wr_wkctr
            op_mch       = wr_mch
            op_date      = last_date
            op_site      = site
            op_line      = prline
            op_earn      = earn
            ophist_recid = recid(op_hist)
            start_run    = "000000"
            stop_run     = "000000".

         display
            op_wkctr
            op_mch
            op_act_run
            op_type
            op_earn
            start_run
            stop_run
            op_trnbr format ">>>>>>>9".

         for first wc_mstr
            fields (wc_dept wc_desc wc_lbr_rate wc_mch wc_wkctr)
            where wc_wkctr = op_wkctr
            and   wc_mch   = op_mch
            no-lock:
         end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* FOR FIRST wc_mstr */

         if available wc_mstr
         then do:

            display
               wc_desc.

            for first dpt_mstr
               fields (dpt_dept dpt_desc)
               where dpt_dept = wc_dept
            no-lock:
            end. /* FOR FIRST dpt_mstr */

            if available dpt_mstr
            then do:

               op_dept = wc_dept.
               display
                  op_dept
                  dpt_desc.
            end. /* IF AVAILABLE dpt_mstr */

            else
               display
                  " " @ dpt_desc.
         end. /* IF AVAILABLE wc_mstr */

         else
            display
               " " @ wc_desc
               " " @ op_dept
               " " @ dpt_desc.

         global_rsntyp = "downtime".

         set_ophist:
         do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


            display
               input_total with frame a.

            set
               op_wkctr
               op_mch
            editing:

               {mfnp.i wc_mstr op_wkctr wc_wkctr op_wkctr
                  wc_wkctr wc_wkctr}

               if recno <> ?
               then
                  display
                     wc_wkctr @ op_wkctr
                     wc_mch   @ op_mch wc_desc.

               for first dpt_mstr
                  fields (dpt_dept dpt_desc)
                  where dpt_dept = wc_dept
                  no-lock:
               end. /* FOR FIRST dpt_mstr */

               if available dpt_mstr
               then do:
                  op_dept = dpt_dept.
                  display
                     op_dept
                     dpt_desc.
               end. /* IF AVAILABLE dpt_mstr */

               else
                  display
                     " " @ dpt_desc.

            end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* SET ... */

            for first wc_mstr
               fields (wc_dept wc_desc wc_lbr_rate wc_mch wc_wkctr)
               where wc_wkctr = op_wkctr
               and   wc_mch   = op_mch
               no-lock:
            end. /* FOR FIRST wc_mstr */

            if not available wc_mstr
            then do:

               /* WORK CENTER DOES NOT EXIST */
               {pxmsg.i &MSGNUM=519 &ERRORLEVEL=3}
               undo, retry.
            end. /* IF NOT AVAILABLE wc_mstr */

            display
               wc_desc.

            for first dpt_mstr
               fields (dpt_dept dpt_desc)
               where dpt_dept = wc_dept
            no-lock:
            end. /* FOR FIRST dpt_mstr */

            if available dpt_mstr
            then do:
               op_dept = dpt_dept.
               display
                  op_dept
                  dpt_desc.
            end. /* IF AVAILABLE dpt_mstr */

            else
               display
                  " " @ dpt_desc.

            do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.

               set
                  op_dept
                  op_act_run
                  op_rsn
                  op_earn
               editing:

                  if frame-field = "op_dept"
                  then do:

                     {mfnp.i dpt_mstr op_dept dpt_dept op_dept
                        op_dept dpt_dept}

                     if recno <> ?
                     then
                        display
                           dpt_dept @ op_dept
                           dpt_desc.
                  end. /* IF frame-field = "op_dept" */

                  else if frame-field = "op_rsn"
                  then do:

                     {mfnp01.i rsn_ref op_rsn rsn_code op_type
                        rsn_type rsn_type}

                     if recno <> ?
                     then
                        display
                           rsn_code @ op_rsn
                           rsn_desc @ rsn_desc1.
                  end. /* ELSE IF frame-field = "op_rsn" */

                  else if frame-field = "op_earn"
                  then do:

                     {mfnp.i ea_mstr op_earn ea_earn op_earn
                        ea_earn ea_earn}

                     if recno <> ?
                     then
                        display
                           ea_earn @ op_earn
                           ea_desc.
                  end. /* ELSE IF frame-field = "op_earn" */

                  else do:
                     status input stline[3].
                     readkey.
                     apply lastkey.
                  end.

               end. /* SET ... */

               for first dpt_mstr
                  fields (dpt_dept dpt_desc)
                  where dpt_dept = op_dept
                  no-lock:
               end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* FOR FIRST dpt_mstr */

               if not available dpt_mstr
               then do:

                  next-prompt
                     op_dept.

                  /* DEPARTMENT DOES NOT EXIST */
                  {pxmsg.i &MSGNUM=532 &ERRORLEVEL=3}
                  undo, retry.
               end. /* IF NOT AVAILABLE dpt_mstr  */

               display
                  dpt_desc.

               if op_rsn = ""
                  and can-find (first rsn_ref where rsn_type = op_type)
               then do:

                  /* PLEASE ENTER REASON CODE */
                  {pxmsg.i &MSGNUM=534 &ERRORLEVEL=3}
                  next-prompt
                     op_rsn.
                  undo, retry.
               end. /* IF op_rsn = "" ... */

               if op_rsn > ""
               then do:

                  for first rsn_ref
                     fields (rsn_code rsn_desc rsn_type)
                     where rsn_code = op_rsn
                     and   rsn_type = op_type
                     no-lock:
                  end. /* FOR FIRST rsn_ref */

                  if available rsn_ref
                  then
                     display
                        rsn_desc @ rsn_desc1.

                  else do:

                     display
                        " " @ rsn_desc1.

                     /* REASON CODE DOES NOT EXIST */
                     {pxmsg.i &MSGNUM=534 &ERRORLEVEL=3}
                     next-prompt
                        op_rsn.
                     undo, retry.
                  end. /* IF NOT AVAILABLE rsn_ref  */

               end. /* IF op_rsn > "" */

               if op_earn > ""
               then do:

                  for first ea_mstr
                     fields (ea_desc ea_earn ea_rate ea_type)
                     where ea_earn = op_earn
                     no-lock:
                  end. /* FOR FIRST ea_mstr */

                  if not available ea_mstr
                  then do:

                     /* INVALID EARNINGS CODE */
                     {pxmsg.i &MSGNUM=4025 &ERRORLEVEL=3}
                     next-prompt
                        op_earn.
                     undo, retry.
                  end. /* IF NOT AVAILABLE ea_mstr  */

                  display
                     ea_desc.

               end. /* IF op_earn > "" */
               else
                  display
                     " " @ ea_desc.

            end. /* DO ON ERROR ... */

            if op_act_run = 0
            then do on error undo, retry with frame b:
/*GUI*/ if global-beam-me-up then undo, leave.


               set
                  start_run
                  stop_run.

               {mfctime.i start_run stop_run}

               op_act_run = elapse.
               display
                  op_act_run.
            end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* IF op_act_run = 0 ... */

            assign
               elapse      = op_act_run
               input_total = input_total + op_act_run.

            display
               input_total with frame a.

            yn = yes.

            /* IS ALL INFORMATION CORRECT */
            {pxmsg.i &MSGNUM=12 &ERRORLEVEL=1 &CONFIRM=yn}

            if yn = no
            then
               undo, retry.

         end. /* SET_OPHIST ... */

         msg-counter = 0.

         repeat:
/*GUI*/ if global-beam-me-up then undo, leave.


            release wo_mstr.
            release wr_route.

            find wo_mstr
               where recid(wo_mstr) = wo_recno
               exclusive-lock
               no-wait no-error.

            if available wo_mstr
            then do:

               find wr_route exclusive-lock
                  where recid(wr_route) = wr_recno no-wait no-error.
            end. /* IF AVAILABLE wo_mstr */

            if locked wo_mstr
               or locked wr_route
            then do:

               if locked wo_mstr
               then
                  locked-file = "wo_mstr".

               else
               if locked wr_route
               then
                  locked-file = "wr_route".

               if msg-counter modulo 100 = 0
               then do:
                  /* Attempting to lock # record. # to exit */
                  {mfmsg03.i 1400 1 locked-file
                     kblabel(""end-error"") """"
                     "fill(""."",(msg-counter / 100) mod 20)" }
                  readkey pause 1.
                  if keyfunction(lastkey) = "end-error"
                  then
                     leave.
                  apply lastkey.

               end. /* IF msg-counter MODULO 100 = 0 */

               msg-counter = msg-counter + 1.
               next.

            end. /* IF locked wo_mstr */

            if available wo_mstr
               and available wr_route
            then
               leave.
         end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* REPEAT */
         hide message.

         if keyfunction(lastkey) = "end-error"
         then
            undo, leave.

         pay_rate = wc_lbr_rate.

         if emp_pay_type = "HR"
            and emp_pay_rate <> 0
         then do:

            pay_rate = emp_pay_rate.

            if earn <> ""
               and available ea_mstr
            then
               pay_rate = pay_rate * ea_rate.

         end. /* IF emp_pay_type = "HR" ... */

         assign
            wr_recno = recid(wr_route)
            wc_recno = recid(wc_mstr)
            op_recno = recid(op_hist).

         {gprun.i ""reoptrc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


      end. /* DO TRANSACTION ... */
   end. /* IF AVAILABLE ln_mstr ... */

   if control_total <> input_total
   then do:

      /* BATCH CONTROL TOTAL DOES NOT EQUAL TOTAL */
      {pxmsg.i &MSGNUM=1151 &ERRORLEVEL=2}
   end. /* IF control_total <> input_total */

end. /* REPEAT */
status input.
